﻿@model PhoneBilling.Models.Report4Model
@{
    ViewBag.Title = "分组话务统计";
    Layout = "~/Views/Shared/_Layout.cshtml"; 
}
<script type="text/javascript" src="@Url.Content("~/Content/js/jquery.treeview.async.js")"></script>
<script type="text/javascript" src="@Url.Content("~/Content/js/jquery.treeview.edit.js")"></script>
<script type="text/javascript" src="@Url.Content("~/Content/js/jquery.treeview.js")"></script>
<script type="text/javascript" src="@Url.Content("~/Content/js/jquery.treeview.sortable.js")"></script>
<link href="@Url.Content("~/Content/js/jquery.treeview.css")" rel="stylesheet" type="text/css" />
<script type="text/javascript">
    function check(id) {
        var checked = $("#" + id).attr("checked");
        if (checked == "checked") {
            $("." + id).attr("checked", checked);
        }
        else {
            $("." + id).removeAttr("checked");
        }
    }

    function change1() {
        $("#check1").attr("disabled", $(".check1").attr("checked") != "checked");
    }

    function change2() {
        $("#check2").attr("disabled", $(".check2").attr("checked") != "checked");
    }

    function change3() {
        $(".areaType").attr("disabled", $(".check3").attr("checked") == "checked");
    }

    function changeAreaType() {
        var str = "";
        $(".areaType").each(function () {
            if ($(this).attr("checked") == "checked") {
                str += $(this).attr("id");
            }
        });
        $("#areaType").val(str);
    }

    function beforeSubmit() {
        var str = "";
        $(".group").each(function () {
            if ($(this).attr("checked") == "checked") {
                if (str == "")
                    str += $(this).attr("id");
                else
                    str += "!" + $(this).attr("id");
            }
        });
        $("#SelectItem").attr("value", str);

        changeAreaType();
    }
    $(document).ready(function () {
        $("#tree").treeview();
    });
    function exportClick() {
        $(".export").val("True");
        beforeSubmit();
    }

    function searchClick() {
        $(".export").val("False");
        beforeSubmit();
    }
    $(document).ready(           
function () 
{  
    $(".myDatePickerClass1 ").datepicker({
        buttonImage: '@Url.Content("~/Content/image/calendar.gif")',               
        dateFormat: 'yy/mm/dd',                 
        showOn: 'button',               
        buttonImageOnly: true ,
        changeMonth:true,              
        changeYear:true,
    });   
    $(".myDatePickerClass2 ").datepicker({
        buttonImage: '@Url.Content("~/Content/image/calendar.gif")',               
        dateFormat: 'yy/mm/dd',                 
        showOn: 'button',               
        buttonImageOnly: true ,
        changeMonth:true,              
        changeYear:true,
    });

    change1();
        change2();
        change3();
}       
);
</script>
@using (Html.BeginForm())
{ 
    @Html.HiddenFor(m => m.SelectItem, new { id = "SelectItem" });
    @Html.HiddenFor(m => m.IsExport, new { @class = "export" })
    <div>
        <div class="col33">
        <h3 class="tlt">请选择分组</h3>
        <ul id="tree" class="treeview-gray">
     @{foreach (var department in Model.DepartmentList)
       {
        <li class="closed"><input type=checkbox id="@department.ID" onclick="check('@department.ID')"/><span class="folder">@department.名称</span> 
        @if (department.分组List.Count > 0)
        {
        <ul>
            @{foreach (var group1 in department.分组List)
              {
                @*<li class="closed"><input type=checkbox id="@group1.ID" class="@department.ID group" onclick="check('@group1.ID')"/><span class="folder">@group1.名称</span> *@
                <li class="closed"><input type=checkbox id="@group1.ID" class="@department.ID group" @*onclick="check('@group1.ID')"*@/><span class="folder">@group1.名称</span>
                            
                @if (group1.分组List.Count > 0)
                {
                <ul>
                    @{foreach (var group2 in group1.分组List)
                      {
                        @*<li class="closed"><input type=checkbox id="@group2.ID" class="@department.ID @group1.ID group" onclick="check('@group2.ID')"/><span class="folder">@group2.名称</span> *@
                        <li class="closed"><input type=checkbox id="@group2.ID" class="@group1.ID group"/><span class="folder">@group2.名称</span> 
                
                        @if (group2.分组List.Count > 0)
                        {
                        <ul>
                            @{foreach (var group3 in group2.分组List)
                              {
                                  <li><input type=checkbox id="@group3.ID" class="@group1.ID @group2.ID group"/><span class="folder">@group3.名称</span> 
                                @*<li><input type=checkbox id="@group3.ID" class="@department.ID @group1.ID @group2.ID group" onclick="check('@group3.ID')"/><span class="folder">@group3.名称</span> *@
                                </li>
                              }}
                        </ul>
                        }
                        </li>
                      }}
                </ul>
                }
                </li>
              }}
        </ul>
        }
        
        </li>
       }}
     </ul>
     </div>
     <div class="col66">
        <h3 class="tlt">时间</h3>
        <div class="input-text">
             @Html.LabelFor(m => m.起始时间)
             @Html.TextBox("起始时间", Model.起始时间.ToString("d"), new { @class = "myDatePickerClass1" }) 
             @Html.TextBox("起始时间Time", Model.起始时间Time.ToString("HH:mm:ss")) 
        </div>
        <div class="input-text">
             @Html.LabelFor(m => m.终止时间)
             @Html.TextBox("终止时间", Model.终止时间.ToString("d"), new { @class = "myDatePickerClass2" }) 
             @Html.TextBox("终止时间Time", Model.终止时间Time.ToString("HH:mm:ss")) 
        </div>
        <h3 class="tlt">话类</h3>
        <div class="input-text">
             @Html.CheckBoxFor(m => m.所有话类, new { onclick = "change3()", @class = "check3" })
             @Html.LabelFor(m => m.所有话类)
             @Html.HiddenFor(m => m.话类, new { id = "areaType" })
    @{
        for (int i = 0;i <Model.话类List.Count;i++)
        {
            @Html.CheckBoxFor(m => m.话类List[i].IsSelected, new { onclick = "changeAreaType()", @class = "areaType", id = Model.话类List[i].ID })
            @Html.Label(string.Format(" {0} ", Model.话类List[i].Name))
        }
    }
        </div>
        <div>
                <input type="submit" value="查询" class="input-submit" onclick="searchClick()" />
                <input type="submit" value="导出Excel" class="input-submit" onclick="exportClick()" />
    </div>
     </div>
    </div>
    
}